package karaoke.servlets;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import karaoke.excepcion.DAOExcepcion;
import karaoke.modelo.Persona;
import karaoke.negocio.GestionLocal;
import karaoke.dao.LocalDAO;

/**
 * Servlet implementation class LocalBuscarServlet
 */
@WebServlet("/RegistraLocalServlet")
public class RegistraLocalServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public RegistraLocalServlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		GestionLocal neg=new GestionLocal();
		
	//	Integer a=Integer.parseInt(request.getParameter("codLocal"));
		
		String b=request.getParameter("txtLocal");
		String c=request.getParameter("txtDirec");
		String d=request.getParameter("txtFono");
		Integer e=Integer.parseInt("txtAdmin"); //Administrador 
		String f=request.getParameter("txtDscr");
	
		try {

			neg.insertar(b, c, d, f, 1);
			
			request.setAttribute("MENSAJE", "Se registro correctamente.");

			
		} catch (karaoke.excepcion.DAOExcepcion e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
			request.setAttribute("MENSAJE", e1.getMessage());
		}

			RequestDispatcher rd = request.getRequestDispatcher("nuevo_local.jsp");
			rd.forward(request, response);

		
		
	}

}
